<?php
class PasswordEvaluator
{
    private $pass = '';
    
    public function __construct( $password )
    {
        $this->pass = $password;
    }
    
    private function difficultCalculate()
    {
        $rating = 0;
        if ( preg_match( "/[A-Z]/", $this->pass ) )
        {
            $rating++;
        }
        if ( preg_match( "/[a-z]/", $this->pass ) )
        {
            $rating++;
        }
        if ( preg_match( "/[0-9]/", $this->pass ) )
        {
            $rating++;
        }
        if ( strlen( $this->pass ) < 6 )
        {
            if ( $rating == 3 )
            {
                $rating = 2;
            }
            else
            {
                $rating = 1;
            }
        }
        if ( preg_match( "/[^A-Za-z0-9]/", $this->pass ) )
        {
            $rating = 0;
        }
        return $rating;
    }

    public function check()
    {
        $difficult = '';
        $raiting = $this->difficultCalculate();
        switch ( $raiting )
        {
            case 1:
                $difficult = 'weak';
                break;
            case 2:
                $difficult = 'good';
                break;
            case 3:
                $difficult = 'strong';
                break;
            default:
                $difficult = 'wrong symbols';
        }
        return $difficult;
    }
}
?>